iLogic/API/VBA error when modifying write-protected (library) documents in Inventor

Autodesk Support

Oct 8, 2023


Products and versions covered


Issue:

The API in Inventor 2017 and earlier allowed documents in read-only (library) folders to be modified. Inventor 2018 and later no longer allow write-protected files, such as content center parts, to be modified by the API or iLogic rules to maintain consistency with the UI behavior.

Possible Error Messages:

"Edits are not allowed on this file"
"Cannot modify the library file"
"Cannot modify properties in a read-only file"
"iLogic rule cannot change Content Center parts"
"Inventor API Runtime error 80004005"
"Method ‘Value’ of object ‘Property’ failed"

Solution:

If your workflow requires modifying read only library documents, consider making the parent folder writable or copying the files to a folder that has write permission. Otherwise, use the work-around below to restore the legacy behavior.


Workaround
Set the hidden _LibraryDocumentModifiable application property.  Only set it to True for the duration of the API calls that need to bypass the read-only document protection.  Leaving it enabled for the entire Inventor session could adversely affect other Inventor UI based features.
 
Here is a VBA segment that shows the correct use of this property:

Dim app As Application
Set app = ThisApplication
Dim oPart As PartDocument
Set oPart = { … }
{ … }

‘ Allow Library document modification
app.[_LibraryDocumentModifiable] = True

‘ Modify a property in a read-only document
oPart.PropertySets.Item(1).Item(1).Value = "test123" 

‘ Revert to default behavior
app.[_LibraryDocumentModifiable] = False


Note:
In VBA, an On Error GoTo, destination should set _LibraryDocumentModifiable to False.  For VB.NET, reset the property in the Finally block of a Try/Catch.

Products:

Inventor Products;

Versions:

2018;


Was this information helpful?


Need help? Ask the Autodesk Assistant!

The Assistant can help you find answers or contact an agent.


What level of support do you have?

Different subscription plans provide distinct categories of support. Find out the level of support for your plan.

View levels of support